/**
 * MineAdmin is committed to providing solutions for quickly building web applications
 * Please view the LICENSE file that was distributed with this source code,
 * For the full copyright and license information.
 * Thank you very much for using MineAdmin.
 *
 * @Author X.Mo<root@imoi.cn>
 * @Link   https://github.com/mineadmin
 */
import type { MaProTableColumns, MaProTableExpose } from '@mineadmin/pro-table'
import type { UseDialogExpose } from '@/hooks/useDialog.ts'

import { ElTag } from 'element-plus'
import { useMessage } from '@/hooks/useMessage.ts'
import { deleteByIds, resetPassword } from '~/base/api/user.ts'
import { ResultCode } from '@/utils/ResultCode.ts'

export default function getTableColumns(dialog: UseDialogExpose, formRef: any, t: any): MaProTableColumns[] {
  const msg = useMessage()
  return [
    // 多选列
    // { type: 'selection', showOverflowTooltip: false},
    // 索引序号列
    // { type: 'index' },
    // 普通列
    { label: 'ID', prop: 'phone' },
    { label: '名称', prop: 'phone' },
    { label: '类型', prop: 'phone' },
    { label: '加价规则', prop: 'phone' },
    // 加价模板  无状态，，预制定价有状态  removeColumn()	移除表格列 appendColumn()	追加表格列
    { label: '状态', prop: 'xxx' ,show:false},
    // 操作列
    {
      type: 'operation',
      label:'操作',
      fixed: 'right',
      width: '180px',
      operationConfigure: {
        type: 'tile',
        actions: [
          {
            name: 'edit',
            icon: 'material-symbols:person-edit',
            text: '编辑',
            onClick: ({ row }) => {
              dialog.setTitle('编辑')
              dialog.open({ formType: 'edit', data: row })
            },
          },
          {
            name: 'del',
            icon: 'mdi:delete',
            text: '删除',
            onClick: ({ row }, proxy: MaProTableExpose) => {
              msg.delConfirm('是否删除').then(async () => {
                const response = await deleteByIds([row.id])
                if (response.code === ResultCode.SUCCESS) {
                  msg.success('删除成功')
                  proxy.refresh()
                }
              })
            },
          }
        ],
      },
    },
  ]
}
